package filter

import (
	. "TaylorTest/app"
	"TaylorTest/model"
	"encoding/json"
	"fmt"
)

//自定义异常处理函数
func ExceptionHandler(context *Context) {
	fmt.Println(context.Exception.Message, context.Exception.Stack)
	if context.IsAjax() {
		result := model.JsonResult{IsSuccess: false, Message: "系统异常，联系管理员\n异常信息：" + context.Exception.Message}
		resultJson, _ := json.Marshal(result)
		fmt.Fprintf(context.ResponseWriter, string(resultJson))
	} else {
		fmt.Fprintf(context.ResponseWriter, context.Exception.Message)
	}
}
